/*****************************************************
** Author:
** Date: 2019-10-28
*
*****************************************************/

#include "testcase.h"
#include "method.h"

/**
 * @brief
 * @param  None
 * @retval None
 */
// void tc0_run(lua_State *L)
// {
//     unsigned char input[4];
//     int i, err, ret;

//     for (i = 0; i < sizeof(input); ++i)
//         input[i] = i * 2;

//     err = lua_arch_io_method1(L, "array2integer", input, sizeof(input), &ret);
//     lua_log_dbg("array2integer err %d ret %d", err, ret);
// }

// void tc1_run(lua_State *L)
// {
//     unsigned char input[4], output[16];
//     int i, err, ret;

//     memset(output, 0x0, sizeof(output));
//     err = lua_arch_io_method2(L, "array2array", input, sizeof(input), output, sizeof(output), &ret);
//     lua_log_dbg("array2array err %d outlen %d", err, ret);

//     for (i = 0; i < ret; ++i)
//         lua_log_inf("output[%d] %02x", i, output[i]);
// }

// void tc2_run(lua_State *L)
// {
//     unsigned char input[4], output[16];
//     int err;

//     memset(output, 0x0, sizeof(output));
//     err = lua_arch_io_method3(L, "array2string", input, sizeof(input), output, sizeof(output));
//     lua_log_dbg("array2string err %d outstr %s", err, output);
// }

// void tc3_run(lua_State *L)
// {
//     int cloudid = 2, err;
//     unsigned char input[16], snapshot[32];
//     unsigned char outstr[64];

//     err = lua_arch_method_data2kv(L, "Devdata2Keyvalue", \
//                                 cloudid, input, sizeof(input), \
//                                 snapshot, sizeof(snapshot), \
//                                 outstr, sizeof(outstr));
//     lua_log_dbg("lua_arch_method_data2kv err %d outstr %s", err, outstr);
// }

// void tc4_run(lua_State *L)
// {
//     int cloudid = 2, err, outlen;
//     unsigned char input[16], snapshot[32];
//     unsigned char output[64];

//     err = lua_arch_method_kve2data(L, "Keyvalue2Devdata", \
//                                 cloudid, input, sizeof(input), \
//                                 snapshot, sizeof(snapshot), \
//                                 output, sizeof(output), &outlen);
//     lua_log_dbg("lua_arch_method_kve2data err %d outlen %d", err, outlen);

//     if (err == 0 && outlen > 0)
//         dump_memory("output", output, outlen);
// }

void tc5_run(lua_State *L)
{
    int status = 7;
    lua_arch_syscom_send(1, &status, sizeof(int));
}

void tc6_run(lua_State *L)
{
    // unsigned int clouds[1] = {0};
    // char data[64];
    // char snapshot[64] = "{\"power\":0,\"brightness\":20}";
    // unsigned char output[128];
    // int ret;

    // clouds[0] = 0;
    // snprintf(data, sizeof(data), "{\"%s\":%d}", "pwr", 1);
    // snprintf(snapshot, sizeof(snapshot), "{\"%s\":%d}", "pwr", 1);
    // ret = lua_arch_clouds_kv2data(L, clouds, 1, (unsigned char *)data, strlen((const char *)data), \
    //                         (unsigned char *)snapshot, strlen((const char *)snapshot), output, sizeof(output));
    // if (ret >= 0)
    //     dump_memory("kv2data", output, ret);

    // clouds[0] = 1;
    // snprintf(data, sizeof(data), "{\"%s\":%d,\"%s\":%d}", "sw", 1, "light", 50);
    // snprintf(snapshot, sizeof(snapshot), "{\"%s\":%d,\"%s\":%d}", "sw", 1, "light", 50);
    // lua_arch_clouds_kv2data(L, clouds, 1, (unsigned char *)data, strlen((const char *)data), \
    //                         (unsigned char *)snapshot, strlen((const char *)snapshot));
}

void tc7_run(lua_State *L)
{
    lua_arch_netstate_notice(6);
}

void tc8_run(lua_State *L)
{
    // syscomid_uart_hdl
    unsigned char test[] = {
        0xbe, 0xbe, 0xbe, 0xbe, 0x02, 0x01, 0x07, 0x00, \
        0x00, 0x00, 0x11, 0x80, 0x01, 0x00, 0x11, 0x22, \
        0x01, 0xed, 0xed
    };
    lua_arch_syscom_send(2, test, sizeof(test));
}

/* End of file */



